package com.jic.market.controller.manage;

import com.jic.common.base.vo.PageResult;
import com.jic.common.base.vo.RestResult;
import com.jic.market.api.manage.CouponTemplateApi;
import com.jic.market.request.manager.coupon.template.CouponTemplateAddGoodsTriggerRequest;
import com.jic.market.request.manager.coupon.template.CouponTemplateAddRequest;
import com.jic.market.request.manager.coupon.template.CouponTemplateAddTriggerRequest;
import com.jic.market.request.manager.coupon.template.CouponTemplateDeleteGoodsRequest;
import com.jic.market.request.manager.coupon.template.CouponTemplateDeleteRequest;
import com.jic.market.request.manager.coupon.template.CouponTemplateEditRequest;
import com.jic.market.request.manager.coupon.template.CouponTemplateListQueryRequest;
import com.jic.market.request.manager.coupon.template.TemplateRequest;
import com.jic.market.response.CouponConfigQueryResponse;
import com.jic.market.response.manager.coupon.template.CouponTemplateListQueryResponse;
import com.jic.market.service.CouponConfigTemplateService;
import com.jic.market.service.CouponGoodsTemplateService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 * @author: gaolanyu
 * @date: 2020-03-02
 * @remark:
 */
@RestController
@RequestMapping("/coupon/template")
@Api(tags = {"优惠券后台管理系统-模版管理"})
@Slf4j
public class CouponTemplateController implements CouponTemplateApi {
    @Autowired
    CouponConfigTemplateService couponConfigTemplateService;
    @Autowired
    CouponGoodsTemplateService couponGoodsTemplateService;

    @ApiOperation(value = "增加优惠券模版基本信息")
    @Override
    public RestResult<String> addCouponTemplate(CouponTemplateAddRequest couponTemplateAddRequest) {
        return couponConfigTemplateService.addCouponTemplate(couponTemplateAddRequest);
    }

    @ApiOperation(value = "查询优惠券模版基本信息")
    @Override
    public RestResult<CouponConfigQueryResponse> queryCouponTemplate(TemplateRequest templateRequest) {
        return couponConfigTemplateService.queryCouponTemplate(templateRequest);
    }

    @Override
    public RestResult<Boolean> addCouponTemplateFromType() {
        return null;
    }

    @ApiOperation(value = "增加优惠券模版商品")
    @Override
    public RestResult<Boolean> addCouponTemplateFromGoods(CouponTemplateAddGoodsTriggerRequest couponTemplateAddGoodsTriggerRequest) {
        return couponGoodsTemplateService.addCouponTemplateFromGoods(couponTemplateAddGoodsTriggerRequest);
    }

    @Override
    public RestResult<Boolean> addCouponTemplateFromStore() {
        return null;
    }

    @Override
    public RestResult<Boolean> addCouponTemplateFromTrigger(CouponTemplateAddTriggerRequest couponTemplateAddTriggerRequest) {
        return null;
    }

    @PostMapping(value = "/query-template-list")
    @ApiOperation(value = "查询优惠券模版列表")
    @Override
    public RestResult<PageResult<CouponTemplateListQueryResponse>> queryCouponTemplateList(CouponTemplateListQueryRequest couponTemplateListQueryRequest) {
        return couponConfigTemplateService.queryCouponTemplateList(couponTemplateListQueryRequest);
    }

    @ApiOperation(value = "删除优惠券模版")
    @Override
    public RestResult<Boolean> deleteCouponTemplate(CouponTemplateDeleteRequest couponTemplateDeleteRequest) {
        return couponConfigTemplateService.deleteCouponTemplate(couponTemplateDeleteRequest);
    }

    @ApiOperation(value = "编辑优惠券模版")
    @Override
    public RestResult<Boolean> editCouponTemplate(CouponTemplateEditRequest couponTemplateEditRequest) {
        return couponConfigTemplateService.editCouponTemplate(couponTemplateEditRequest);
    }

    @ApiOperation(value = "删除优惠券模版商品")
    @Override
    public RestResult<Boolean> deleteCouponTemplateGoods(CouponTemplateDeleteGoodsRequest couponTemplateDeleteGoodsRequest) {
        return couponGoodsTemplateService.deleteCouponTemplateGoods(couponTemplateDeleteGoodsRequest);
    }
}
